<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:a="http://www.w3.org/2005/Atom"
                xmlns:ac="http://brightcontent.net/ns/app-client"
                xmlns:dyn="http://exslt.org/dynamic"
                xmlns:xh="http://www.w3.org/1999/xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                exclude-result-prefixes="ac xh #default">

 <xsl:output method="html" omit-xml-declaration="yes" indent="yes" />

 <xsl:param name="ac:base_url" />
 <xsl:param name="ac:form_action">.</xsl:param>
 <xsl:param name="ac:atom_title" />
 <xsl:param name="ac:atom_content" />
 <xsl:param name="ac:atom_summary" />
 <xsl:param name="ac:atom_slug" />
 <xsl:param name="ac:atom_updated" />
 <xsl:param name="ac:atom_published" />
 <xsl:param name="ac:err_atom_title" />
 <xsl:param name="ac:err_atom_content" />
 <xsl:param name="ac:err_atom_updated" />
 <xsl:param name="ac:check_params">Nope not working</xsl:param>

 <xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>Atom Publishing Protocol Client</title>
  <xsl:variable name="css" select="concat($ac:base_url, '/static/css/styles.css')" />
  <link rel="stylesheet" type="text/css" href="{$css}" />
 </head>
 <body>
  Params? <xsl:value-of select="$ac:check_params" />
  <hr />
  <xsl:apply-templates />
 </body>
</html>
 </xsl:template>
 
 <xsl:template match="a:entry">
  <form action="{$ac:form_action}" method="POST" enctype="multipart/form-data">
   <input type="submit" name="submit" value="submit" />
   <fieldset class="options" id="media-forms">
    <legend>Media Entries</legend>
    <div>
     media...
    </div>
   </fieldset>
  
   <fieldset class="options" id="extra-post-info">
    <legend>Optional Details</legend>
    <div>
     <label for="atom_slug">Slug</label><br />
     <input type="text" name="atom_slug" value="{$ac:atom_slug}" />
    </div>
    <div>
     <label for="atom_updated">Updated (Defaults to Now)</label>
     <xsl:if test="$ac:err_atom_updated">
      <span class="error_msg"><xsl:value-of select="$ac:err_atom_updated" /></span>
     </xsl:if>
     <br />
     <input type="text" name="atom_updated" value="{$ac:atom_updated}" />
    </div>
    <div>
     <label for="atom_published">Published (Defaults to Now)</label><br />
     <input type="text" name="atom_published" value="{$ac:atom_published}" />
    </div>
   </fieldset>

   <fieldset id="main">
    <legend>Add an Entry</legend>
    <div>
     <label for="atom_title">Title</label>
     <xsl:if test="$ac:err_atom_title">
      <span class="error_msg"><xsl:value-of select="$ac:err_atom_title" /></span>
     </xsl:if>
     <br />
     <input type="text" name="atom_title" value="{$ac:atom_title}" />
    </div>
    <div>
     <label for="atom_content">Content</label>
     <xsl:if test="$ac:err_atom_content">
      <span class="error_msg"><xsl:value-of select="$ac:err_atom_content" /></span>
     </xsl:if>
     <br />
     <textarea name="atom_content" rows="20" cols="80"><xsl:value-of select="$ac:atom_content" /><xsl:text> </xsl:text>
     </textarea>
    </div>
    <div>
     <label for="atom_summary">Summary</label><br />
     <textarea name="atom_summary" rows="10" cols="80">
      <xsl:value-of select="$ac:atom_summary" /><xsl:text> </xsl:text>
     </textarea>
    </div>
   </fieldset>
  </form>
 </xsl:template>
 
 <xsl:template name="collection-info">
  <!--
   <fieldset>
    <legend>Collection</legend>
     <div>
      <label for="collection_url">Collection URL</label>
      <input type="text" name="collection_url" value="${collection_url}" />
      <br />
      <label for="collection_username">Username:</label>
      <input type="text" name="collection_username" value="${collection_username}" />
      <br />
      <label for="collection_password">Password:</label>
      <input type="password" name="collection_password" value="${collection_password}" />
     </div>
   </fieldset>
  -->
 </xsl:template>

 <xsl:template match="node()">
  <xsl:copy>
   <xsl:copy-of select="@* | text()" />
   <xsl:apply-templates />
  </xsl:copy>
 </xsl:template>
 
</xsl:stylesheet>